<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="error_Page.jsp" %>
<%!
	Connection conn=null;
	Statement st=null;
	String sid,sname,FromName,To,From,Message;
	int chk=0;
	%>
	
<%
	sid=(String)session.getAttribute("id");
	sname=(String)session.getAttribute("name");
if(sid==null)
	response.sendRedirect("http://localhost:8080/expired.html");
else
try{
	FromName=request.getParameter("T2");
	From=request.getParameter("T1");
	To=request.getParameter("T3");
	Message=request.getParameter("M1");
	
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	conn=DriverManager.getConnection("jdbc:odbc:sis");
	st=conn.createStatement();
	chk=st.executeUpdate("INSERT INTO Message VALUES('"+FromName+"','"+From+"','"+To+"','"+Message+"')");
	if(chk==1)
	out.println("Message Sent Successfully!");
	else
	out.println("Problems Occured During Message Sending");
}
catch(Exception e){
	out.println("Exception Occured");
     e.printStackTrace();
     out.println(e.getMessage());
}
%>
<html>
<head>
<title>Testing JSP</title>
<meta http-equiv="refresh"  content="5 ; url=Home.jsp">
<!-- <SCRIPT LANGUAGE=JAVASCRIPT>
setTimeout("top.location.href = 'http://localhost:8080/Home.jsp'",2000); 
</SCRIPT> //-->
</head>
<body>
<p><strong><font color="#999999" face="Courier New, Courier, mono">Redirecting 
  you to Home Page</font></strong> </p>
<p align="center"> <img border="0" src="images/redirect.JPG" width="200" height="250"></p>
</body>
</html>
